package com.xingdata.jjxc.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xingdata.jjxc.R;
import com.xingdata.jjxc.adapter.CarInfoListViewAdapter.ViewHolder;
import com.xingdata.jjxc.enty.OBDEntity;
import com.xingdata.jjxc.views.CircleImageView;

public class DrivingHabitsAdapter extends BaseAdapter {
	private ArrayList<OBDEntity> obdEntities;
	private Context mContext;

	public DrivingHabitsAdapter(Context context, ArrayList<OBDEntity> entities) {
		this.mContext = context;
		this.obdEntities = entities;
	}

	@Override
	public int getCount() {
		return obdEntities == null ? 0 : obdEntities.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return obdEntities.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView==null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.drivinghabits_item, null);
			viewHolder.title=(TextView) convertView.findViewById(R.id.drivinghabits_title);
			viewHolder.value=(TextView) convertView.findViewById(R.id.drivinghabits_value);
			convertView.setTag(viewHolder);
		}else {
			viewHolder=(ViewHolder) convertView.getTag();
		}
		viewHolder.title.setText(obdEntities.get(position).getTitle());
		viewHolder.value.setText(obdEntities.get(position).getValue());
		return convertView;
	}

	
	final class ViewHolder {
		private TextView title;
		private TextView value;
	}
}
